def welcome():
    # 占位符
    print('-' * 20)
    print('1:添加学院')
    print('2:删除学院')
    print('3:修改学院')
    print('4:查询学院')
    print('5:显示所有学员学院')
    print('6:退出系统学院')
    print('-' * 20)


def add_info():
    print('-----添加学院------')
    new_id = input('请输入学号:')
    new_name = input('请输入姓名:')
    new_tel = input('请输入电话:')
    for e in info:
        if new_id == e['id'] or new_name == e['name']:
            print('用户已存在!不能重复列表')
            return
    dict1 = {}
    dict1['id'] = new_id
    dict1['name'] = new_name
    dict1['tel'] = new_tel
    info.append(dict1)
    print(f'添加成功!学院信息{info}')


def del_info():
    """
    删除学院功能:
    学院姓名存在，则删除
    不存在这提示
    :return:
    """
    # for语句:便利列表，判断姓名存在的情况，删除该学院
    for e in info:
        if del_name == e['name']:
            info.remove(e)
            print('删除成功!')
            break
            # 学院姓名不存在的情况，提示信息
            # else实在循环正常结束之后执行
            # 诺循环不正常结束（列入break），else不会被执行
    else:
        print('该学员不存在')
    print(info)


def modify_into(del_name):
    modify_name=input('请输入修改的学员姓名:')
    global info
    for e in info:
        if modify_name == e['id']:
            e['tel']=input('请输入手机号');
            break
    else:
        print('该学员不存在')
    print (info)


def select_info():
    def search_info():
        search_name=input('请输入要查找的学员姓名:')
        global  info
        for i in info:
            if search_name==i['name']:
                print('查找到的学员信息如下:-----')
                print(f"该学员的学号是{i['id']},{i['name']},{i['tel']}")
                break
        else:
            print('该学员不存在')


def select_all():
    def print_all():
        print('学号\t姓名\t手机号')
        for i in info:
            print(f'{i["id"]}\t{i["name"]}\t{i["tel"]}')


info = []


def del_name():
    pass


while True:
    welcome()
    choose = input('请选择您需要的功能序号:')
    if choose == '1':
        add_info()
    elif choose == '2':
        del_name=input('请输入要则删除的学员姓名')
        del_info()
    elif choose == '3':
        modify_into(del_name)
    elif choose == '4':
        select_info()
    elif choose == '5':
        select_all()
    elif choose == '6':
        flag = input('确定庶退出?yes or no')
        if flag == 'yes':
            break
    else:
        print('输出有误!请重新选择您需要的功能序号')
